package com.aaa.sso.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @fileName:SwaggerConfig
 * @description:
 * @author:zhz
 * @createTime:2020/11/30 10:53
 * @version:1.0.0
 */
@Configuration
public class SwaggerConfig {
    /**
     * 创建一个docket
     * @return
     */
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //.enable(false)  //swagger不能访问
                .select()
                //配置要扫描接口的方式
                .apis(RequestHandlerSelectors.basePackage("com.aaa.sso.controller"))
                //.apis(RequestHandlerSelectors.withClassAnnotation(ApiOperation.class))
                //路径过滤
                .paths(PathSelectors.any())
                .build();
    }

    /**
     * apiInfo
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("单点登录系统")
                .description("更多请关注http://bbs.aaajy.net/")
                .termsOfServiceUrl("http://bbs.aaajy.net/")
                .contact("qy119")
                .version("1.0")
                .build();
    }
}
